//
//  FFRecvPayItemCell.m
//  LLWallet
//
//  Created by tt on 2020/12/16.
//

#import "FFRecvPayItemCell.h"

@implementation FFRecvPayItemModel

- (Class)cell {
    return FFRecvPayItemCell.class;
}

@end

@interface FFRecvPayItemCell ()

@property(nonatomic,strong) UIView *boxView;

@property(nonatomic,strong) UIImageView *icon;
@property(nonatomic,strong) UILabel *titleLbl;

@end

@implementation FFRecvPayItemCell

- (void)setupUI {
    [super setupUI];
    
    self.backgroundColor = [UIColor clearColor];
    
    [self.contentView addSubview:self.boxView];
    [self.boxView addSubview:self.icon];
    [self.boxView addSubview:self.titleLbl];
}

- (void)refresh:(FFRecvPayItemModel *)model {
    [super refresh:model];
    
    self.titleLbl.text = model.title;
    [self.titleLbl sizeToFit];
    
    self.icon.image = model.icon;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.boxView.lim_height = self.contentView.lim_height;
    self.boxView.lim_left = 10.0f;
    self.boxView.lim_width = self.contentView.lim_width - self.boxView.lim_left*2;
   
    
    self.icon.lim_left = 15.0f;
    self.icon.lim_centerY_parent = self.contentView;
    
    self.titleLbl.lim_left = self.icon.lim_right + 10.0f;
    self.titleLbl.lim_centerY_parent = self.contentView;
    
    self.arrowImgView.lim_left =self.contentView.lim_width - 30.0f - self.arrowImgView.lim_width;
    
}

- (UIImageView *)icon {
    if(!_icon) {
        _icon = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 24.0f, 24.0f)];
    }
    return _icon;
}

- (UILabel *)titleLbl {
    if(!_titleLbl) {
        _titleLbl = [[UILabel alloc] init];
        _titleLbl.textColor = [UIColor whiteColor];
        _titleLbl.font = [[WKApp shared].config appFontOfSize:16.0f];
    }
    return _titleLbl;
}

- (UIView *)boxView {
    if(!_boxView) {
        _boxView = [[UIView alloc] init];
        _boxView.backgroundColor = [UIColor colorWithRed:240.0f/255.0f green:240.0f/255.0f blue:240.0f/255.0f alpha:0.1f];
        _boxView.layer.masksToBounds = YES;
        _boxView.layer.cornerRadius = 4.0f;
    }
    return _boxView;
}

@end
